package com.cdcas;

import java.util.ArrayList;
import java.util.DoubleSummaryStatistics;
import java.util.List;
import java.util.stream.Stream;

public class OrderTest {
    public static void main(String[] args) {
        List<Order> orders = new ArrayList<>();
        orders.add(new Order("java",80,1000));
        orders.add(new Order("python",78.9,600));
        orders.add(new Order("C",59.88,1800));
        orders.add(new Order("java 进阶内容",150,1500));
        Stream<Order> stream = orders.stream();
        DoubleSummaryStatistics result = stream.
                filter((ele)->ele.getName().toLowerCase().contains("java")).
                mapToDouble((orderObj)->orderObj.getPrice()*orderObj.getAmount()).summaryStatistics();
        System.out.println("订单总量：" + result.getCount());
        System.out.println("订单总费用：" + result.getSum());
        System.out.println("平均价格：" + result.getAverage());
        System.out.println("最高价格：" + result.getMax());
        System.out.println("最低价格：" + result.getMin());
    }
}
